<template>
    <div>
        <el-form :inline="true" :model="formInline" class="demo-form-inline">
    <el-form-item label="挂号状态">
        <el-select v-model="formInline.state" placeholder="活动区域">
        <el-option label="所有" value=""></el-option>
        <el-option label="未处理" value="1"></el-option>
        <el-option label="已拒绝" value="2"></el-option>
        <el-option label="已同意" value="3"></el-option>
        </el-select>
    </el-form-item>
    <el-form-item>
        <el-button type="primary" @click="onSubmit">查询</el-button>
    </el-form-item>
    </el-form>
      <el-descriptions :column='4' title="挂号记录" border v-for="obj in registerList" :key="obj.id" > 
            <el-descriptions-item label="患者姓名"> {{ obj.userName }} </el-descriptions-item>
            <el-descriptions-item label="挂号时间">{{ obj.createTime.replace('T',',') }}</el-descriptions-item>
            <el-descriptions-item label="症状" v-if="obj.symptom !=='' " style="color:red">
                {{ JSON.parse(obj.symptom).map(item => {return item.name || item.symName }) + '' || '不明确' }}
            </el-descriptions-item>
            <el-descriptions-item label="备注">
            <el-tag size="small">{{ obj.remark || '无' }}</el-tag>
            </el-descriptions-item>
            <el-descriptions-item label="患病部位"> {{ obj.position || '暂无'}}</el-descriptions-item>
            <el-descriptions-item label="主治医生"> {{ obj.doctorName }}</el-descriptions-item>
            <el-descriptions-item label="科室"> {{ obj.depName }}</el-descriptions-item>
            <el-descriptions-item label="诊室"> {{ obj.consName }}</el-descriptions-item>
            <el-descriptions-item label="状态"> {{ obj.state == 1 ? "未处理" : obj.state == 2 ? "已拒绝" : "已同意"}}</el-descriptions-item>
            <el-descriptions-item label="操作" v-if="obj.state == 1"> <el-button type="warning" @click="go(obj)">前往处理</el-button></el-descriptions-item>

        </el-descriptions>
        <PatientText ref="PatientText" @updateState="updateState"/>
  </div>
</template>

<script>
import { doctorGetRegisteredById } from '@/api/user'
import { getUserID } from '@/utils/auth'
import PatientText from './patientText'
export default {
    name:'medicaDoctor',
    components:{PatientText},
    data(){
        return{
            registerList:[],
            formInline:{
                state:""
            },
        }
    },
    mounted(){
        this.doctorGetRegistered()
    },
    methods:{
        updateState(){
            console.log("sdfsdf")
            this.doctorGetRegistered();
        },
        onSubmit() {
            this.doctorGetRegistered();
      },
        // 获取挂号记录
       async doctorGetRegistered(){
           console.log(getUserID())
           this.registerList = await doctorGetRegisteredById(getUserID(), this.formInline.state)
        },
    //  前往处理
    go(obj){
        if(obj.symptom){
            obj.symptom = JSON.parse(obj.symptom);
        }
        this.$refs.PatientText.obj = obj;
        this.$refs.PatientText.dialogVisible = true
    }
    }
}
</script>

<style>

</style>